package com.aaa.service.impl;

import com.aaa.dao.ViewTestResultSdsDao;
import com.aaa.entity.ViewTestResultSds;
import com.aaa.service.ViewTestResultSdsService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author ：dudu（12232347710@qq.com）
 * @date ：Created in 2022/7/7 19:24
 * @description：
 * @modified By：
 */
@Service
public class ViewTestResultSdsServiceImpl implements ViewTestResultSdsService {
    @Autowired
    private ViewTestResultSdsDao viewTestResultSdsDao;
    @Override
    public Page selectResultSds(ViewTestResultSds viewTestResultSas) {
        if (null!=viewTestResultSas.getLimit()){
            Page<ViewTestResultSds> page = PageHelper.startPage(viewTestResultSas.getPage(),viewTestResultSas.getLimit());
        }
        List<ViewTestResultSds> viewTestResultSas1 = viewTestResultSdsDao.selectResultSds();
        Page tblTestersResultPage = (Page) viewTestResultSas1;
        return tblTestersResultPage;
    }

    @Override
    public List<ViewTestResultSds> selectResultOneSds(Integer testerId) {
        return viewTestResultSdsDao.selectResultOneSds(testerId);
    }
    /**
     * @create by: dudu（1223234771@qq.com）
     * @description: 查询数据图
     * @create time: 2022/7/8 8:55
     * @param
     * @return
     */
    @Override
    public Map<String, Integer> seleTeseSdsUser() {
        int normal =0;
        int mild=0;
        int moderate=0;
        int severe=0;
        List<ViewTestResultSds> viewSdss = viewTestResultSdsDao.selectSds();
        for (ViewTestResultSds viewSds : viewSdss) {
            double fordwordScoring = viewSds.getFordwordScoring();
            double reveseScoring = viewSds.getReverseScoring();
            double sum=(fordwordScoring+reveseScoring)*1.25;
            if (sum<=53){
                normal++;
            }else if (sum<63){
                mild++;
            }else if (sum<73){
                moderate++;
            }else {
                severe++;
            }
        }
        Map<String,Integer> map=new HashMap<>();
        map.put("normal",normal);
        map.put("mild",mild);
        map.put("moderate",moderate);
        map.put("severe",severe);
        return map;
    }
}
